package servlet;

import bean.SupplieroutBean;
import util.JdbcUtil;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class OutboundsuModifyServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
           doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int soutid =Integer.parseInt(request.getParameter("soutid"));
        String sql ="SELECT * FROM supplier_out Where soutid=?";
        try {
            PreparedStatement ps = JdbcUtil.getConnection().prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
            ps.setInt(1,soutid);
            ResultSet set = ps.executeQuery();
            set.absolute(1);
            SupplieroutBean suo = new SupplieroutBean();
            suo.setSoutid(set.getInt(1));
            suo.setName(set.getString(2));
            suo.setPerson(set.getString(3));
            suo.setOutid(set.getInt(4));
            suo.setEmail(set.getString(5));
            suo.setTel(set.getString(6));
            suo.setAddress(set.getString(7));
            HttpSession session = request.getSession();
            session.setAttribute("suo",suo);
            request.getRequestDispatcher("outboundsumodify.jsp").forward(request,response);

        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
    }
}

